package client_V1;
// <editor-fold defaultstate="collapsed" desc="Imports">
import lib.StreamSocket;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
// </editor-fold>
/**
 * @file Receiver.java
 *
 * @version 0.1
 * @author Chris Sewell 10008342
 */
public class Receiver extends Thread {
    // <editor-fold defaultstate="collapsed" desc="Attributes">

    StreamSocket serverStream;
    String serverInput;
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Constructors">

    public Receiver(StreamSocket serverStream) {
        this.serverStream = serverStream;
    }
    // </editor-fold> 
    // <editor-fold defaultstate="collapsed" desc="Methods">

    @Override
    public void run() {
        while (true) {
            serverInput = serverStream.recieveString();
            if (serverInput == null) {//If null string received kill connection from server
                try {
                    serverStream.kill();
                } catch (IOException ex) {
                    Logger.getLogger(Receiver.class.getName()).log(Level.SEVERE, null, ex);
                }
                return;
            }
            System.out.println(serverInput);
        }
    }
    // </editor-fold> 
}
